package com.ys.erp.framework.response;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.HashSet;

/**
 * @author lwj
 * @date 2024/9/2
 */
public class ResponseOpenHandler implements Condition {

    private static final HashSet<String> IGNORE_RESPONSE_PROJECT_NAME_SET =  new HashSet<String>();

    static {
        IGNORE_RESPONSE_PROJECT_NAME_SET.add("gateway");
    }

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        // 获取项目名称
        String projectName = context.getEnvironment().getProperty("spring.application.name");
        // 根据自定义属性的值来决定是否满足条件
        return !IGNORE_RESPONSE_PROJECT_NAME_SET.contains(projectName);
    }

}
